package com.loong.mapper;

import com.loong.pojo.Product;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProductMapper {
    /**
     * 根据tid查询商品数量
     * @param tid 商品类型id
     * @return 商品数量
     */
    @Select("SELECT COUNT(1) FROM product WHERE tid = #{tid}")
    long selectCountByTid(@Param("tid") String tid);

    @Select( "SELECT * FROM product WHERE tid = #{tid} LIMIT #{page},#{pageSize}")
    List<Product> selectProductByPage(@Param("tid") String tid,@Param("page") int page, @Param("pageSize") int pageSize);

    @Select("SELECT * FROM product WHERE pid = #{pid}")
    Product selectProductByPid(@Param("pid") int pid);

}
